administrators = function() {
	//权限设置窗体
	var administratorAutoWin = null;
	//标志位
	var administratorFlag = true;
	//数据返回值
	var administratorDataRes = null;
	//添加或修改用户窗体
	var administratorAddOrModifyWin = null;
	//选择所属组织窗体
	var administratorChooseOrganWin = null;
	//搜索后台用户窗体
	var administratorSearchWin = null;
	return {
		/*--------------------------------------窗体定义--------------------------------------------*/
		panel : function() {
			//后台用户STORE
			var adminstore = new Store({
				fields: ['id', 'username', 'enabled', 'truename', 'nickName', 'sex', 
				         'sbirthday', 'mail', 'phone', 'ip', 'slastTime', 'sregisterDate', 
				         'sorgan', 'sorganName', 'ssystemType', 'ssystemTypeName', 
				         'motto', 'qq', 'remark', 'limited', 'pic'],
				proxy: {
			        type: 'ajax',
			        url: '../admin/administrator.jspx?index',
			        reader: {
			            type: 'json',
			            root: 'datas',
			            totalProperty: 'total'
			        }
			    },
			    autoLoad: false
			});
			
			//默认加载数据
			adminstore.removeAll();
			adminstore.currentPage = 1;
			adminstore.proxy.extraParams = {};
			adminstore.load();
			
			//后台用户列表
			var pageToolBar = Ext.create('Ext.PagingToolbar', {
	            store: adminstore,
	            draggable : false,
	            displayInfo: true
	        });
			var admingrid = new Grid({
				title: '后台用户列表',
				id: 'administratorgrid',
				region: 'center',
				store: adminstore,
				minColumnWidth: 35,
				stripeRows: true,
				bbar : pageToolBar,
				tbar: [{
					text: '刷新',
					scale: 'medium',
					iconCls: 'icon-refresh',
					handler: function() {
						administrators.refreshAdministratorAction();
					}
				}, "-", {
					text: '搜索',
					scale: 'medium',
					iconCls: 'icon-search',
					handler: function() {
						administrators.searchAdministratorAction();
					}
				}, "-", {
					text: '添加',
					id: 'administratorAdd',
					scale: 'medium',
					iconCls: 'icon-add',
					disabled: true,
					handler: function() {
						administrators.addAdministratorAction();
					}
				}, "-", {
					text: '修改',
					id: 'administratorEdit',
					scale: 'medium',
					iconCls: 'icon-edit',
					disabled: true,
					handler: function() {
						administrators.modifyAdministratorAction();
					}
				}, "-", {
					text: '删除',
					id: 'administratorRemove',
					scale: 'medium',
					iconCls: 'icon-remove',
					disabled: true,
					handler: function() {
						administrators.removeAdministratorAction();
					}
				}, "-", {
					text: '权限设置',
					id: 'administratorConfig',
					scale: 'medium',
					iconCls: 'icon-config',
					disabled: true,
					handler: function() {
						administrators.autoConfigAction();
					}
				}],
				columns: [
		             new Ext.grid.RowNumberer(),
		             {header: '序号', dataIndex: 'id', hidden: true},
		             {header: '登录名', dataIndex: 'username', width: 120},
		             {header: '真实姓名', dataIndex: 'truename', width: 120},
		             {header: '昵称', dataIndex: 'nickName', width: 120},
		             {header: '角色类型', dataIndex: 'ssystemTypeName', width: 120},
		             {header: '状态', dataIndex: 'enabled', width: 120, renderer: function(v) {
		            	 if (v) return "<font color=blue>激活</font>";
		            	 else return "<font color=red>失效</font>";
		             }},
		             {header: '所属组织', dataIndex: 'sorganName', width: 180},
		             {header: '是否限制', dataIndex: 'limited', width: 100, renderer: function(v) {
		            	 if (v) return "<font color=red>是</font>";
		            	 else return "否";
		             }},
		             {header: '最近登录时间', dataIndex: 'slastTime', width: 150}
				]
			});
			
			var panel = new Panel({
				layout: 'border',
				border: false,
				items: [admingrid]
			});
			return panel;
		},
		
		//权限设置窗体
		autoConfigWin: function(obj) {
			administratorDataRes = RequestByUrl('../admin/administrator.jspx?configOFauto', {
				id: obj
			});
			if (administratorAutoWin == null) {
				//角色数据集
				var rolestore = new Store({
					fields: ['id', 'name', 'organ', 'remark', 'rule'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/administrator.jspx?configOFrole'
				    },
				    autoLoad: false,
				    listeners: {
				    	load: function(fn) {
				    		administratorFlag = false;
				    		var rolesels = Ext.getCmp('administratorRoleGrid').getSelectionModel();
				    		var roles = administratorDataRes.rolestr.split(";");
							var ook = [];
							for (var i = 0; i < roles.length - 1; i++) {
								ook.push(rolestore.getById(parseInt(roles[i])));
							}
							rolesels.select(ook);
							administratorFlag = true;
				    	}
				    }
				});
				
				//选择组件
				var rolesm = Ext.create('Ext.selection.CheckboxModel', {
					mode: 'SIMPLE'
				});
				
				//权限数据集
				var autostore = new TreeStore({
					fields: ['id', 'text'],
			        proxy: {
			            type: 'ajax',
			            url: '../admin/administrator.jspx?configOFaction',
			            reader: {
			                type: 'json',
			                root: 'children'
			            }
			        },
			        autoLoad: false,
			        listeners: {
				    	load: function(fn, node, records, successful, eOpts) {
				    		var autos = administratorDataRes.autostr.split(";");
				    		for (var i = 0; i < autos.length - 1; i++) {
				    			var cnode = autostore.getNodeById(parseInt(autos[i]));
								cnode.set('checked', true);
								cnode.bubble(function(node){
					                node.set('checked', true);  
					                return true;   
					            });
							}
				    	}
			        }
			    });
				autostore.load();
				//权限树形
				var tree = new Tree({
					id: 'administratorautotree',
			        store: autostore,
			        region: 'east',
			        hideHeaders: true,
			        rootVisible: false,
			        width: '30%',
			        lines: false,
			        disableSelection: true,
			        title: '权限列表',
			        collapsible: true,
			        listeners:{
			            "checkchange": function(node, state) {
			                if (node.get('leaf')) {
			                    //子节点选中   
			                	if (state) {
			                		node.bubble(function(node){
				                        node.set('checked', state);  
				                        return true;   
				                    });
			                	}
			                } else {
			                	if (state) {
			                		node.bubble(function(node){
				                        node.set('checked', state);  
				                        return true;   
				                    });
			                	} else {
			                		node.cascade(function(node){
				                        node.set('checked', state);  
				                        return true;   
				                    });
			                	}
			                }  
			            }
			        }
				});
				
				//权限设置窗体定义
				administratorAutoWin = new Window({
					id: 'administratorAutoConfigWin',
				    title: '权限设置',
				    height: 550,
				    width: 750,
				    layout: 'border',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'gridpanel',
				    	title: '角色列表',
				    	id: 'administratorRoleGrid',
				    	store: rolestore,
				    	minColumnWidth: 35,
				    	region: 'center',
						stripeRows: true,
						selModel: rolesm,
						columns: [
						  {header: '序号', dataIndex: 'id', hidden: true},
				          {header: '名称', dataIndex: 'name', width: 130},
				          {header: '所属组织', dataIndex: 'organ', width: 130},
				          {header: '备注说明', dataIndex: 'remark', width: 130},
				        ],
						listeners: {
							select: function(fn, rec, index, eOpts) {
								administrators.selectRoleAction();
							},
							deselect: function(fn, rec, index, eOpts) {
								administrators.selectRoleAction();
							}
						}
				    }, tree
				    ],
				    buttons: [{
				    	text: '确定',
				    	handler: function() {
				    		administrators.autoConfigSureAction();
				    	}
				    }, {
				    	text: '取消',
				    	handler: function() {
				    		administratorAutoWin.hide();
				    	}
				    }],
				    listeners: {
				    	hide: function() {
				    		rolesm.deselectAll();
				    		var sels = Ext.getCmp('administratorautotree').getChecked();
				    		for (var i = 0; i < sels.length; i++) {
				    			sels[i].set('checked', false);
				    		}
				    	}
				    }
				});
			} else {
				//autogrid = Ext.getCmp('administratorautotree').getStore().load();
				var autostore = Ext.getCmp('administratorautotree').getStore();
				var autos = administratorDataRes.autostr.split(";");
	    		for (var i = 0; i < autos.length - 1; i++) {
	    			var cnode = autostore.getNodeById(parseInt(autos[i]));
					cnode.set('checked', true);
					cnode.bubble(function(node){
		                node.set('checked', true);  
		                return true;   
		            });
				}
			}
			administratorAutoWin.show();
			Ext.getCmp('administratorRoleGrid').getStore().load();
		},
		
		//添加或修改后台用户窗体
		addOrModifyWin: function() {
			if (administratorAddOrModifyWin == null) {
				var enabledstore = new Store({
					fields: ['str', 'val'],
					data: [
					   { str: '激活', val: true },
					   { str: '失效', val: false }
					]
				});
				var limitstore = new Store({
					fields: ['str', 'val'],
					data: [
					   { str: '是', val: true },
					   { str: '否', val: false }
					]
				});
				var typestore = new Store({
					fields: ['id', 'name'],
					proxy: {
				        type: 'ajax',
				        url: '../admin/administrator.jspx?indexOFsystemType'
					},
					autoLoad: true
				});
				//必选项标志
				var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
				administratorAddOrModifyWin = new Window({
					id: 'administratorAddOrModifyWin',
				    title: '后台用户信息编辑',
				    height: 540,
				    width: 650,
				    layout: 'fit',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'administratorAddOrModifyForm',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
						autoScroll: true,
						fieldDefaults: {
				            labelWidth: 75
				        },
				        defaultType: 'textfield',
				        defaults: {
				            anchor: '100%'
				        },
				        items: [{
				        	name: 'id',
				        	hidden: true
				        }, {
			                xtype: 'fieldset',
			                title: '基本信息',
			                defaultType: 'textfield',
			                layout: 'hbox',
			                defaults: {
			                    anchor: '100%'
			                },
			                items: [{
			                    xtype: 'fieldcontainer',
			                    layout: 'anchor',
			                    flex: 1,
			                    defaultType: 'textfield',
			                    defaults: {
			                    	labelWidth: 75,
			                    	anchor: '100%'
			                    },
			                    items: [{
			                    	name: 'username',
			                        fieldLabel: '登录名',
			                        afterLabelTextTpl: required,
			                        allowBlank: false,
			                        minLength: 6
			                    }, {
			                    	name: 'password',
			                        fieldLabel: '登录密码',
			                        afterLabelTextTpl: required,
			                        inputType: 'password',
			                        allowBlank: false,
			                        minLength: 6
			                    }, {
			                    	name: 'repassword',
			                        fieldLabel: '确认密码',
			                        afterLabelTextTpl: required,
			                        allowBlank: false,
			                        inputType: 'password',
			                        validator: function(value) {
			                            var password = this.previousSibling('[name=password]');
			                            return (value === password.getValue()) ? true : '与登录密码不相一致.';
			                        }
			                    }, {
			                    	name: 'truename',
			                        fieldLabel: '真实姓名',
			                        afterLabelTextTpl: required,
			                        allowBlank: false
			                    }, {
			                    	name: 'nickName',
			                        fieldLabel: '昵称',
			                        afterLabelTextTpl: required,
			                        allowBlank: false
			                    }]
			                }, {
			                    xtype: 'fieldcontainer',
			                    layout: 'anchor',
			                    flex: 1,
			                    defaultType: 'textfield',
			                    defaults: {
			                    	labelWidth: 75,
			                    	anchor: '100%'
			                    },
			                    items: [{
			                    	xtype: 'combo',
			                        name: 'enabled',
			                        fieldLabel: '当前状态',
			                        afterLabelTextTpl: required,
			                        allowBlank: false,
			                        store: enabledstore,
			                        displayField: 'str',
			                        valueField: 'val',
			                        queryMode: 'local',
			                        editable: false
			                    }, {
			                    	xtype: 'combo',
			                        name: 'ssystemType',
			                        fieldLabel: '角色类型',
			                        afterLabelTextTpl: required,
			                        allowBlank: false,
			                        store: typestore,
			                        displayField: 'name',
			                        valueField: 'id',
			                        queryMode: 'local',
			                        editable: false
			                    }, {
						        	xtype: 'fieldcontainer',
						        	fieldLabel: '所属组织',
						        	afterLabelTextTpl: required,
					                msgTarget : 'side',
						        	defaults: {
						        		hideLabel: true
				                    },
				                    layout: 'hbox',
				                    items: [{
				                    	xtype: 'textfield',
							        	name: 'sorganName',
							        	flex: 1,
							        	readOnly: true,
							        	allowBlank: false
							        },
				                    {
							        	xtype: 'button',
				                        text: '选择',
				                        width: 50,
				                        handler: function() {
				                        	administrators.chooseOrganAction();
				                        }
				                    }]
				                }, {
						        	name: 'sorgan',
						        	hidden: true
						        }, {
						        	xtype: 'combo',
			                        name: 'limited',
			                        fieldLabel: '是否限制',
			                        afterLabelTextTpl: required,
			                        allowBlank: false,
			                        store: limitstore,
			                        displayField: 'str',
			                        valueField: 'val',
			                        queryMode: 'local',
			                        editable: false
						        }]
			                }]
			            }, {
			                xtype: 'fieldset',
			                title: '详细信息',
			                defaultType: 'textfield',
			                layout: 'hbox',
			                defaults: {
			                    anchor: '100%'
			                },
			                items: [{
			                    xtype: 'fieldcontainer',
			                    layout: 'anchor',
			                    flex: 1,
			                    defaultType: 'textfield',
			                    defaults: {
			                    	labelWidth: 75,
			                    	anchor: '100%'
			                    },
			                    items: [{
			                    	xtype: 'radiogroup',
			                        fieldLabel: '性别',
			                        allowBlank: false,
			                        items: [
			                            { boxLabel: '男', name: 'sex', inputValue: '1', checked: true },
			                            { boxLabel: '女', name: 'sex', inputValue: '2' },
			                            { boxLabel: '保密', name: 'sex', inputValue: '3' }
			                        ]
			                    }, {
			                        fieldLabel: '联系电话',
			                        name: 'phone'
			                    }, {
			                    	fieldLabel: '邮箱地址',
			                    	name: 'mail',
			                    	vtype: 'email'
			                    }, {
			                    	fieldLabel: '联系QQ',
			                    	name: 'qq'
			                    }, {
			                    	fieldLabel: '座右铭',
			                    	name: 'motto'
			                    }, {
			                    	fieldLabel: '备注说明',
			                    	xtype: 'textareafield',
			                    	name: 'remark'
			                    }]
			                }, {
			                    xtype: 'fieldcontainer',
			                    layout: 'hbox',
			                    flex: 1,
			                    height: 150,
			                    style: 'margin-top: -14px',
			                    items: [
			                            {
			                    	xtype: 'form',
			                    	hidden: true,
			                    	items: []
			                    }, {
			                    	xtype: 'panel',
			                    	id: 'administratorImg',
			                    	style: 'margin-left: 65px',
			                    	html: '<img src="../manage/pic/noneimg.jpg" class="imgCls" />'
			                    },
			                    {
				                    xtype: 'fieldcontainer',
				                    layout: 'vbox',
				                    style: 'margin-left: 8px',
				                    defaultType: 'button',
				                    items: [{
				                    	xtype: 'form',
				                    	id: 'administratorsPicForm',
				                    	layout: 'vbox',
				                    	border: false,
				                    	height: 100,
				                    	items: [{
				                    		xtype: 'filefield',
				                    		name: 'file',
				                    		hideLabel: true,
				                    		buttonOnly: true,
				                    		buttonText: '选择图片',
				    			        	listeners: {
				    			        		change: function(fn, val, eOpts) {
				    			        			var str = val.substring(val.indexOf('.') + 1);
				    			        			if (str.toLowerCase() != 'png') {
				    			        				Ext.Msg.alert('提示', '请选择扩展名为png的文件！');
				    			        				this.setRawValue('');
				    			        			}
				    			        		}
				    			        	}
					                    }, {
					                    	xtype: 'button',
					                    	text: '上传图片',
					                    	id: 'administratorUploadImg',
					                    	style: 'margin-top: 8px',
					                    	handler: function() {
					                    		var fom = this.up('form').getForm();
					                    		var val = fom.findField('file').getValue();
					                    		if (val == undefined || val == '') {
					                    			Ext.Msg.alert('提示', '请选择要上传的图片！');
					                    			return false;
					                    		} else {
					                    			administrators.submitPicAction(fom);
					                    		}
					                    	}
					                    }, {
					                    	xtype: 'button',
					                    	text: '刷新图片',
					                    	style: 'margin-top: 12px',
					                    	handler: function() {
					                    		administrators.refreshPicAction();
					                    	}
					                    }]
				                    }]
			                    }]
			                }]
			            }],
			            buttons: [{
			            	text: '确定',
			            	handler: function() {
			            		var fom = Ext.getCmp('administratorAddOrModifyForm').getForm();
				        		if (fom.isValid()) {
				        			administrators.formSubmitAction(fom);
				        		}
			            	}
			            }, {
			            	text: '取消',
			            	handler: function() {
			            		administratorAddOrModifyWin.hide();
			            	}
			            }]
				    }],
			        listeners: {
			        	hide: function(fn, eOpts) {
			        		Ext.getCmp('administratorAddOrModifyForm').getForm().reset();
			        	}
			        }
				});
			}
			administratorAddOrModifyWin.show();
		},
		
		//选择组织窗体
		chooseOrganWin: function() {
			if (administratorChooseOrganWin == null) {
				var store = new TreeStore({
					fields: ['id', 'name'],
	                proxy: {
	                    type: 'ajax',
	                    url: '../admin/administrator.jspx?indexOForgan'
	                }
			    });
				
				administratorChooseOrganWin = new Window({
					title: '选择组织',
					height: 400,
					width: 450,
					closeAction: 'hide',
					layout: 'fit',
					modal: true,
					items: [{
						xtype: 'treepanel',
						id: 'administratorChooseOrganTree',
						store: store,
						loadingText: '加载组织中...',
						rootVisible: false,
						tbar: [{
							text: '刷新',
							scale: 'medium',
							iconCls: 'icon-refresh',
							handler: function() {
								store.load();
							}
						}],
						columns: [{
			                xtype: 'treecolumn',
			                text: '组织名称',
			                flex: 0.7,
			                sortable: true,
			                dataIndex: 'name'
				        }],
				        listeners: {
				        	itemdblclick: function(fn, record, item, index, e, eOpts) {
				        		administrators.chooseOrganSureAction();
				        	}
				        }
					}],
					buttons: [{
						text: '确定',
						handler: function() {
							administrators.chooseOrganSureAction();
						}
					}, {
						text: '取消',
						handler: function() {
							administratorChooseOrganWin.hide();
						}
					}]
				});
			}
			administratorChooseOrganWin.show();
		},
		
		//搜索窗体定义
		searchWin: function() {
			if (administratorSearchWin == null) {
				administratorSearchWin = new Window({
					id: 'administratorSearchWin',
				    title: '搜索后台用户',
				    height: 200,
				    width: 400,
				    layout: 'fit',
				    closeAction: "hide",
				    modal: true,
				    items: [{
				    	xtype: 'form',
				    	id: 'administratorSearchForm',
				    	frame: false,
						autoHeight: true,
						bodyPadding: 15,
						autoScroll: true,
						fieldDefaults: {
				            labelWidth: 75,
				            anchor: '95%'
				        },
				        defaultType: 'textfield',
				        items: [{
				        	name: 'username',
				        	fieldLabel: '登录名'
				        }, {
				        	name: 'truename',
				        	fieldLabel: '真实姓名'
				        }, {
				        	name: 'nickName',
				        	fieldLabel: '昵称'
				        }],
				        buttons: [{
				        	text: '确定',
				        	handler: function() {
				        		administrators.searchAdministratorSureAction();
				        	}
				        }, {
				        	text: '取消',
				        	handler: function() {
				        		administratorSearchWin.hide();
				        	}
				        }]
				    }],
			        listeners: {
			        	hide: function(fn, eOpts) {
			        		Ext.getCmp('administratorSearchForm').getForm().reset();
			        	}
			        }
				});
			}
			administratorSearchWin.show();
		},
		
		/*--------------------------------------触发事件定义--------------------------------------*/
		//权限设置事件
		autoConfigAction: function() {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要权限设置的后台用户！');
			} else {
				administrators.autoConfigWin(sel[0].get('id'));
			}
		},
		
		//选择角色触发事件
		selectRoleAction : function() {
			if (administratorFlag) {
				var rolesm = Ext.getCmp('administratorRoleGrid').getSelectionModel();
				var autosm = Ext.getCmp('administratorautotree').getChecked();
				var autostore = Ext.getCmp('administratorautotree').getStore();
				for (var i = 0; i < autosm.length; i++) {
					autosm[i].set('checked', false);
				}
				var sels = rolesm.getSelection();
				var ook = [];
				for (var k = 0; k < sels.length; k++) {
					var sel = sels[k].get('rule').split(';');
					for (var i = 0; i < sel.length - 1; i++) {
						var cnode = autostore.getNodeById(parseInt(sel[i]));
						cnode.set('checked', true);
						cnode.bubble(function(node){
			                node.set('checked', true);  
			                return true;   
			            });
					}
				}
			}
		},
		
		//权限设置确定事件
		autoConfigSureAction: function() {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			var rolesels = Ext.getCmp('administratorRoleGrid').getSelectionModel().getSelection();
			var autosels = Ext.getCmp('administratorautotree').getChecked();
			var rolestr = "0";
			for (var i = 0; i < rolesels.length; i++) {
				rolestr = rolestr + "," + rolesels[i].get('id');
			}
			var autostr = "";
			for (var i = 0; i < autosels.length; i++) {
				if (autosels[i].get('id') > 0) {
					autostr = autostr + autosels[i].get('id') + ";";
				}
			}
			var res = RequestByUrl('../admin/administrator.jspx?config', {
				id: sel[0].get('id'),
				rolestr: rolestr,
				autostr: autostr
			});
			if (res.success) {
				Ext.Show.msg(res.msg, '');
				administratorAutoWin.hide();
			}
		},
		
		//添加后台用户事件
		addAdministratorAction: function() {
			administrators.addOrModifyWin();
			Ext.getCmp('administratorImg').body.update('<img src="../manage/pic/noneimg.jpg" class="imgCls" />');
			Ext.getCmp('administratorUploadImg').setDisabled(true);
		},
		
		//选择组织事件
		chooseOrganAction: function() {
			administrators.chooseOrganWin();
		},
		
		//选择组织确定事件
		chooseOrganSureAction: function() {
			var sel = Ext.getCmp('administratorChooseOrganTree').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要指定的组织！');
			} else {
				var fom = Ext.getCmp('administratorAddOrModifyForm').getForm();
				fom.findField('sorganName').setRawValue(sel[0].get('name'));
				fom.findField('sorganName').focus();
				fom.findField('sorgan').setRawValue(sel[0].get('id'));
				administratorChooseOrganWin.hide();
			}
		},
		
		//修改后台用户事件
		modifyAdministratorAction: function() {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要修改的后台用户！');
			} else {
				administrators.addOrModifyWin();
				var fom = Ext.getCmp('administratorAddOrModifyForm').getForm();
				fom.loadRecord(sel[0]);
				fom.findField('password').setValue('        ');
				fom.findField('repassword').setValue('        ');
				var pic;
				if (sel[0].get('pic')) {
					pic = '../file/pic/user/' + sel[0].get('id') + '.png';
				} else {
					pic = '../manage/pic/noneimg.jpg';
				}
				Ext.getCmp('administratorImg').body.update('<img src="' + pic + '" class="imgCls" />');
				Ext.getCmp('administratorUploadImg').setDisabled(false);
			}
		},
		
		//表单提交事件
		formSubmitAction: function(fom) {
			var url = '../admin/administrator.jspx?edit';
			var id = fom.findField('id').value;
			if (id == '') {
				url = '../admin/administrator.jspx?add';
			}
			var res = FormSubmit(fom, url, {}, function(obj) {
				if (obj.obj) {
					Ext.getCmp('administratorgrid').getStore().load();
					administratorAddOrModifyWin.hide();
				}
			});
		},
		
		//上传图片事件
		submitPicAction: function(fom) {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			var res = FormSubmit(fom, '../admin/administrator.jspx?editOFpic', {
				id: sel[0].get('id')
			}, function(obj) {
				sel[0].set('pic', true);
				Ext.getCmp('administratorsPicForm').getForm().findField('file').setValue('');
				var pic = '../file/pic/user/' + sel[0].get('id') + '.png?_time=' + (new Date()).valueOf();
				Ext.getCmp('administratorImg').body.update('<img src="' + pic 
						+ '" onerror="this.src=\'../manage/pic/noneimg.jpg\'" class="imgCls" />');
			});
		},
		
		//刷新图片事件
		refreshPicAction: function() {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			if (sel.length < 1) return false;
			var pic;
			if (sel[0].get('pic')) {
				pic = '../file/pic/user/' + sel[0].get('id') + '.png?_time=' + (new Date()).valueOf();
			} else {
				pic = '../manage/pic/noneimg.jpg';
			}
			Ext.getCmp('administratorImg').body.update('<img src="' + pic + '" class="imgCls" />');
		},
		
		//删除后台用户
		removeAdministratorAction: function() {
			var sel = Ext.getCmp('administratorgrid').getSelectionModel().getSelection();
			if (sel.length < 1) {
				Ext.Msg.alert('提示', '请选择要删除的后台用户！');
			} else {
				Ext.MessageBox.confirm('确认', '您确认要删除该后台用户吗？', function(btn) {
					if (btn == "yes") {
						var res = RequestByUrl('../admin/administrator.jspx?remove', {
							id: sel[0].get('id')
						});
						if (res.ok) {
							Ext.getCmp('administratorgrid').getStore().load();
						}
						Ext.Show.msg(res.msg, '');
					}
				});
			}
		},
		
		//搜索后台用户事件
		searchAdministratorAction: function() {
			administrators.searchWin();
		},
		
		//搜索后台用户确定事件
		searchAdministratorSureAction: function() {
			var fom = Ext.getCmp('administratorSearchForm').getForm();
			var store = Ext.getCmp('administratorgrid').getStore();
			store.removeAll();
			store.currentPage = 1;
			store.proxy.extraParams = {
					username: fom.findField('username').value,
					truename: fom.findField('truename').value,
					nickName: fom.findField('nickName').value
			};
			store.load();
			administratorSearchWin.hide();
		},
		
		//刷新后台用户事件
		refreshAdministratorAction: function() {
			Ext.getCmp('administratorgrid').getStore().load();
		}
	};
}();